package com.alpha.eceasy.mall.api.entity;

import com.alpha.eceasy.extension.BaseFormInfo;
import com.alpha.eceasy.mall.api.dto.MallCommodityDTO;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

import java.io.Serial;

/**
 * @author huangpengfei
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("mall_commodity")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "商品主表")
public class MallCommodity extends BaseFormInfo<MallCommodity> {
    @Serial
    private static final long serialVersionUID = 641655770L;
    @Schema(description = "商品主名称")
    @NotBlank(message = "商品主名称不能为空")
    private String commodityName;
    /**
     * 已弃用，移至商品规格表（MallCommoditySpecification）
     */
    @Schema(description = "产品guid")
    @Deprecated(since = "2024-05-11", forRemoval = true)
    private String infoProductGuid;
    @Schema(description = "图标/封面图")
//    @NotBlank
    private String icon;
    @Schema(description = "商品聚合信息的最小单位")
    private String spu;

    public MallCommodity(MallCommodityDTO dto) {
        BeanUtils.copyProperties(dto, this);
    }
}